package com.clusterswisdom.horn.api.tmall.action.scitem;

import java.util.HashMap;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.action.AbstractTmallAction;
import com.clusterswisdom.horn.api.tmall.action.scitem.ThreadOfStore.KeepToDb;

public class ExtendItemStoreAction extends AbstractTmallAction implements HornAction{
	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		//表名
		String tableName ="t_daystock";
		
		//是否为最后一次库存传输
		boolean isEnd = KeepToDb.setIntoDb(param, tableName);
		
		//是最后一次库存传输后开启库存设置
		if(isEnd){
			KeepToDb keepToDb = new KeepToDb();
			KeepToDb.updateItemByItemId(KeepToDb.getDataFromTmall(tableName), tableName);
			//同步天猫库存到天猫中
			keepToDb.KeepToTmall(tableName);
			//将天猫中没有库存的先初始化库存
			keepToDb.initialToTmall(tableName);
			
		}
		return new HornResponse(true, "成功");
	}
}
